﻿/*  PandoraUnleashed
    An open source API for the Pandora music service
    Copyright © 2011 Saulius Milevicius

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PandoraUnleashed.Data
{
    class GenreData
    {
        public String categoryName;
        public List<Station> stations;

        /// <summary>
        /// Genre Data constructor
        /// </summary>
        /// <param name="categoryName">Genre category name</param>
        public GenreData(String categoryName)
        {
            this.categoryName = categoryName;
            this.stations = new List<Station>();
        }

        /// <summary>
        /// Genre Data constructor
        /// </summary>
        /// <param name="json">Hashtable of json params</param>
        public GenreData(Hashtable json)
        {
            this.stations = new List<Station>();
            this.categoryName = (String)json["categoryName"];
            ArrayList list = (ArrayList)json["stations"];
            for (int i = 0; i < list.Count; ++i)
                stations.Add(new Station((Hashtable)list[i]));
        }
    }

    class Station
    {
        String artUrl;
        String id;
        String name;
        String token;

        /// <summary>
        /// Station constructor
        /// </summary>
        /// <param name="id">Stations id</param>
        /// <param name="name">Stations name</param>
        /// <param name="token">Stations token</param>
        /// <param name="artUrl">Stations art url</param>
        public Station(String id, String name, String token, String artUrl)
        {
            this.id = id;
            this.name = name;
            this.token = token;
            this.artUrl = artUrl;
        }

        /// <summary>
        /// Station constructor
        /// </summary>
        /// <param name="json">Hashtable of json params</param>
        public Station(Hashtable json)
        {
            this.id = (String)json["stationId"];
            this.name = (String)json["stationName"];
            this.token = (String)json["stationToken"];
            if (json.ContainsKey("artUrl"))
                this.artUrl = (String)json["artUrl"];
            else
                this.artUrl = "";
        }
    }
}
